﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;

namespace CityLife
{
 
	public partial class DesignSelector : UserControl
	{
        private List<UIElement> _items;

        public DesignSelector()
        {
            // Required to initialize variables
            InitializeComponent();

            _items = new List<UIElement>();

      
  
        }



        public ComboBox InnerCombo
        {
            get
            {
                return this.ComboBox;
            }

        }



        public static bool IsOpened { get; set; }


        public void AddImage(string name)
        {
            Image image = new Image();
            Uri uri = new Uri(Application.Current.Host.Source.AbsoluteUri.Replace(Application.Current.Host.Source.LocalPath, "") + "/images/ToolThumbs/"+name+".png", UriKind.Absolute);
            ImageSource img = new System.Windows.Media.Imaging.BitmapImage(uri);
            image.Width = 30;
            image.Height = 30;
            image.SetValue(Image.SourceProperty, img);
            image.HorizontalAlignment = HorizontalAlignment.Center;
        

          //  ComboBox.Items.Add(image);
          //  ComboBox.DataContext = image;
        }

		
		  public void AddDesign(UIElement uielement)
        {
            ICityDesign x = (uielement as ICityDesign);
            if (x != null)
                  Items.Add(x.Info);

        
        }

 

     
		
        public ItemCollection Items
        {
            get { return this.ComboBox.Items; }
        }


        //public  object Tag
        //{
        //    set { this.ComboBox.Tag = value; }
        //    get { return this.ComboBox.Tag; }
        //}

 

        private void ComboBox_DropDownOpened(object sender, EventArgs e)
        {
            IsOpened = true;
        }

        private void ComboBox_DropDownClosed(object sender, EventArgs e)
        {
            if (((sender as ComboBox).SelectedItem) != null)
            {
                MainPage.Editor.ActiveTool.Design = ((sender as ComboBox).SelectedItem as ShopInfo).DesignType;
                MainPage.Editor.ActiveTool.info = ((sender as ComboBox).SelectedItem as ShopInfo);
            }
            IsOpened = false;
        }

        private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {


         MainPage.Editor.ActiveTool.Design = (e.AddedItems[0] as ShopInfo).DesignType;
          MainPage.Editor.ActiveTool.info = (e.AddedItems[0] as ShopInfo);
         //   MainPage.Editor.ActiveTool.ToolType = (e.AddedItems[0] as ShopInfo).ToolType;
           // MainPage.Editor.ActiveTool.CursorType = (e.AddedItems[0] as ShopInfo).CursorType;
        }
	}
}